/*
 * @Author: ZhanXie
 * @Date: 2020-05-19 16:39:48
 * @LastEditors: ZhanXie
 * @LastEditTime: 2020-05-20 14:50:46
 * @Description:
 * @FilePath: /webpack-cli/src/reducers/counter.js
 */
import { DECREMENT, INCREMENT } from '../actions/actionType';

const initState = {
  count: 0,
};

export default function counter(state = initState, action) {
  switch (action.type) {
    case INCREMENT:
      return { ...state, count: state.count + 1 };
    case DECREMENT:
      return { ...state, count: state.count - 1 };
    default:
      return state;
  }
}
